package bulk_param.view;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

import bulk_param.controller.AideIndicatifInactivationController;
import bulk_param.controller.ButtonInactivationController;
import bulk_param.controller.ColorErrorInactivationController;
import bulk_param.controller.RadioButtonInactivationController;
import bulk_param.controller.SetSelectedBoxInactivationController;
import bulk_param.modele.JTextFieldLimit;
import bulk_param.modele.ReadCVS;

import com.toedter.calendar.JDateChooser;
import com.toedter.calendar.JTextFieldDateEditor;

public class Inactive_Contact_Num_View extends JPanel{	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
		
	private Font fontBouton = new Font("Broadway", Font.BOLD, 12);
	private JPanel panelInactivePoint;
	private JPanel inactivation_Panel;
	private JPanel panelTrafic;
	public JDateChooser dateChooser;
	public JTextFieldDateEditor dateEditor;
	public JButton btInactiver ;
	private String selectDate = "Séléction de Date";
	public JRadioButton national, international;
	private ButtonGroup typeTrafic;
	public JLabel lbVide,lbVide2,lbPays, lbZABPQ, lbInactiveDt;
	public JComboBox<String> cbPays;
	public JTextField txtZABPQ;
	private ReadCVS readCVS;
	//Liste des contenus combobox
	public ArrayList<String> listPaysFixeMobile;
	
	public Inactive_Contact_Num_View(){
		
	}
	
	public JPanel panelInactivation(){						
		
		
		//Remplissage combobox Pays
		readCVS = new ReadCVS();
		listPaysFixeMobile=readCVS.countryDictionary();
		
		//Panel Open_Point
		panelInactivePoint = new JPanel();
		panelInactivePoint.setLayout(new BorderLayout());
		
		//Type de trafic
		panelTrafic= new JPanel();
		panelTrafic.setLayout(new FlowLayout());
		national = new JRadioButton("National");
		national.setSelected(true);
		international = new JRadioButton("International");
		typeTrafic =new ButtonGroup();
		typeTrafic.add(national);
		typeTrafic.add(international);
		panelTrafic.add(national);
		panelTrafic.add(international);		
		
		
		//GridBagLayout pour les champs d'activation du point ZABPQ
        inactivation_Panel = new JPanel();
        inactivation_Panel.setLayout(new GridBagLayout());
        
		// libelle premiere ligne
        GridBagConstraints gridBagConstraintsTrafic = new GridBagConstraints();
        gridBagConstraintsTrafic.gridx = 1;
        gridBagConstraintsTrafic.gridy = 0;
        gridBagConstraintsTrafic.insets = new Insets(20, 0, 20, 0);
        gridBagConstraintsTrafic.anchor = gridBagConstraintsTrafic.WEST;
        inactivation_Panel.add(panelTrafic, gridBagConstraintsTrafic);
        
        GridBagConstraints gridBagConstraintsPointZABPQ = new GridBagConstraints();
        lbZABPQ = new JLabel("Point(0ZABPQ) : ");
        gridBagConstraintsPointZABPQ.gridx = 0;
        gridBagConstraintsPointZABPQ.gridy = 1;
        gridBagConstraintsPointZABPQ.insets = new Insets(20, 100, 20, 5);
        gridBagConstraintsPointZABPQ.anchor = gridBagConstraintsPointZABPQ.WEST;
        inactivation_Panel.add(lbZABPQ, gridBagConstraintsPointZABPQ);
        
        GridBagConstraints gridBagConstraintsPoint = new GridBagConstraints();
        txtZABPQ = new JTextField(12);
        txtZABPQ.setDocument(new JTextFieldLimit(7));
        gridBagConstraintsPoint.gridx = 1;
        gridBagConstraintsPoint.gridy = 1;
        gridBagConstraintsPoint.insets = new Insets(20, 5, 20, 5);
        gridBagConstraintsPoint.anchor = gridBagConstraintsPoint.WEST;
        inactivation_Panel.add(txtZABPQ, gridBagConstraintsPoint);
          
        GridBagConstraints gridBagConstraintsPays = new GridBagConstraints();
        lbPays = new JLabel("Pays : ");
        gridBagConstraintsPays.gridx = 2;
        gridBagConstraintsPays.gridy = 1;
        gridBagConstraintsPays.insets = new Insets(20, 5, 20, 5);
        gridBagConstraintsPays.anchor = gridBagConstraintsPays.WEST;
        inactivation_Panel.add(lbPays, gridBagConstraintsPays);	
        lbPays.setVisible(false);
        
        GridBagConstraints gridBagConstraintsSelectPays = new GridBagConstraints();
        cbPays = new JComboBox<String>();
        cbPays.addItem(null);
        for (int i=0;i<listPaysFixeMobile.size();i++){
        	cbPays.addItem(listPaysFixeMobile.get(i));
        }
        cbPays.setPreferredSize(new Dimension(150, 20));
        gridBagConstraintsSelectPays.gridx = 3;
        gridBagConstraintsSelectPays.gridy = 1;
        gridBagConstraintsSelectPays.insets = new Insets(20, 5, 20, 5);
        gridBagConstraintsSelectPays.anchor = gridBagConstraintsSelectPays.WEST;
        inactivation_Panel.add(cbPays, gridBagConstraintsSelectPays);
        cbPays.setVisible(false);
   
        
     // libelle deuxieme ligne
        GridBagConstraints gridBagConstraintsInactiveDt = new GridBagConstraints();
        lbInactiveDt = new JLabel("Date d'inactivation : ");
        gridBagConstraintsInactiveDt.gridx = 0;
        gridBagConstraintsInactiveDt.gridy = 2;
        gridBagConstraintsInactiveDt.insets = new Insets(20, 100, 20, 5);
        gridBagConstraintsInactiveDt.anchor = gridBagConstraintsInactiveDt.WEST;
        inactivation_Panel.add(lbInactiveDt, gridBagConstraintsInactiveDt);
        
        GridBagConstraints gridBagConstraintsTxtInactiveDt = new GridBagConstraints();    
        dateChooser = new JDateChooser();
        dateChooser.setDateFormatString("dd/MM/yyyy");
        dateChooser.setPreferredSize(new Dimension(135, 21));
        dateEditor = (JTextFieldDateEditor)dateChooser.getDateEditor();
        dateEditor.setEditable(false);
        dateEditor.setText(selectDate);
        dateEditor.setForeground(Color.gray);
        gridBagConstraintsTxtInactiveDt.gridx = 1;
        gridBagConstraintsTxtInactiveDt.gridy = 2;
        gridBagConstraintsTxtInactiveDt.insets = new Insets(20, 5, 20, 5);
        gridBagConstraintsTxtInactiveDt.anchor = gridBagConstraintsTxtInactiveDt.WEST;
        inactivation_Panel.add(dateChooser, gridBagConstraintsTxtInactiveDt);

 
        //lieblle boutton
        GridBagConstraints gridBagConstraintsbtValider = new GridBagConstraints();
        btInactiver = new JButton("Inactiver");
        btInactiver.setPreferredSize(new Dimension(135,21));
        btInactiver.setBackground(Color.black);
        btInactiver.setFont(fontBouton);
        btInactiver.setForeground(Color.getHSBColor(39,233,255));
        gridBagConstraintsbtValider.gridx = 1;
        gridBagConstraintsbtValider.gridy = 3;
        gridBagConstraintsbtValider.insets = new Insets(20, 5, 20, 5);
        gridBagConstraintsbtValider.anchor = gridBagConstraintsbtValider.WEST;
        inactivation_Panel.add(btInactiver, gridBagConstraintsbtValider); 
        
		//ZABPQ OPEN_CONTACT LAYOUT
        
		panelInactivePoint.add(inactivation_Panel,BorderLayout.WEST);
		
		
		national.addActionListener(new RadioButtonInactivationController(this));
		international.addActionListener(new RadioButtonInactivationController(this));
		btInactiver.addActionListener(new ButtonInactivationController(this));
		cbPays.addMouseListener(new ColorErrorInactivationController(this));
		txtZABPQ.addMouseListener(new ColorErrorInactivationController(this));
		dateEditor.addMouseListener(new ColorErrorInactivationController(this));
		dateChooser.addMouseListener(new ColorErrorInactivationController(this));
		
		//aide indicatif pays
		cbPays.addActionListener(new SetSelectedBoxInactivationController(this));
		txtZABPQ.addMouseListener(new AideIndicatifInactivationController(this));
		
		return panelInactivePoint;
						
	}		
}
